public class XSLconverter {
	
	String preamble;
	static RegexMatcher regexMatcher = new RegexMatcher();
	
	public XSLconverter() {
		preamble = "";
	}

	public String convertLoopVariableToXSL(String defStringToConvert) 
	{
		
		String convString = preamble;

		//Get first two letters between @ and :
		String firstTwoLettersOfAPVariable = regexMatcher.getRegexMatch("(?<=@)[a-zA-Z]{2,}(?=\\$)", defStringToConvert);

		//Get first set of numbers after :
		String numbersAfterColon = regexMatcher.getRegexMatch("(?<=:)[0-9]+", defStringToConvert);
		
		convString = convString + firstTwoLettersOfAPVariable;

		convString = convString + "n_";

		convString = convString + numbersAfterColon;
		
		convString = wrapInXSL(convString);

		return convString;
	}
	
	public String convertConstantToXSL(String defStringToConvert) 
	{
		String convString = wrapInXSL("'" + defStringToConvert + "'");
		return convString;
	}
	
	public String wrapInXSL(String string) 
	{
		String returnedString = "<xsl:value-of select=\"" + string + "\"/>";
		return returnedString;
	}

	
	public String wrapIfInXSL(String test, String result)
	{
		return "<xsl:choose><xsl:when test=\"" + test + "\">" + result + "</xsl:when></xsl:choose>";
	}

	public String convertNumberIfToXSL(int abs) {
		// TODO Auto-generated method stub
		String returnString = preamble + "Cond_" + Math.abs(abs);		
		return wrapInXSL(returnString);
	}
}